-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate binds to Android and iOS #53
Conversation
# Conflicts: # .github/workflows/publish-ios.yaml
WalkthroughThe changes introduce new GitHub Actions workflows for automating the publishing of Android and iOS packages upon release creation. Additionally, several scripts and configuration files are added to support building and testing mobile applications using Rust and Xcode. The modifications expand the project structure to include a mobile package, enhance dependency management, and implement comprehensive testing for cryptographic functionalities. Changes
Poem
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (1)
packages/kos-sdk/src/chain.rs (1)
22-30
: Add a comment to explain the removal of the chain code0
.The removal of the chain code
0
should be documented to explain why it is necessary.Add a comment to explain the removal of the chain code
0
:- // remove the NONE chain + // Remove the NONE chain (chain code 0) because it is not a valid chain. map.remove(&0);
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (2)
Cargo.lock
is excluded by!**/*.lock
packages/kos-mobile/android/gradle/wrapper/gradle-wrapper.jar
is excluded by!**/*.jar
Files selected for processing (30)
- .github/workflows/publish-android.yaml (1 hunks)
- .github/workflows/publish-ios.yaml (1 hunks)
- Cargo.toml (2 hunks)
- Makefile (1 hunks)
- packages/kos-mobile/Cargo.toml (1 hunks)
- packages/kos-mobile/android/.gitignore (1 hunks)
- packages/kos-mobile/android/build.gradle.kts (1 hunks)
- packages/kos-mobile/android/gradle.properties (1 hunks)
- packages/kos-mobile/android/gradle/libs.versions.toml (1 hunks)
- packages/kos-mobile/android/gradle/wrapper/gradle-wrapper.properties (1 hunks)
- packages/kos-mobile/android/gradlew (1 hunks)
- packages/kos-mobile/android/gradlew.bat (1 hunks)
- packages/kos-mobile/android/lib/build.gradle.kts (1 hunks)
- packages/kos-mobile/android/lib/src/main/AndroidManifest.xml (1 hunks)
- packages/kos-mobile/android/lib/src/test/kotlin/uniffi/kos_mobile/KOSTest.kt (1 hunks)
- packages/kos-mobile/android/settings.gradle.kts (1 hunks)
- packages/kos-mobile/build_android.sh (1 hunks)
- packages/kos-mobile/build_clean.sh (1 hunks)
- packages/kos-mobile/build_ios.sh (1 hunks)
- packages/kos-mobile/build_source.sh (1 hunks)
- packages/kos-mobile/ios/.gitignore (1 hunks)
- packages/kos-mobile/ios/framework/.gitignore (1 hunks)
- packages/kos-mobile/ios/framework/KOSMobile/KOSMobile.xcodeproj/project.pbxproj (1 hunks)
- packages/kos-mobile/ios/framework/KOSMobile/KOSMobile.xcodeproj/xcshareddata/xcschemes/KOSMobile.xcscheme (1 hunks)
- packages/kos-mobile/ios/framework/KOSMobile/KOSMobile/KOSMobile.h (1 hunks)
- packages/kos-mobile/ios/framework/KOSMobile/KOSMobileTests/KOSMobileTests.swift (1 hunks)
- packages/kos-mobile/src/bin/uniffi-bindgen.rs (1 hunks)
- packages/kos-mobile/src/lib.rs (1 hunks)
- packages/kos-sdk/Cargo.toml (1 hunks)
- packages/kos-sdk/src/chain.rs (3 hunks)
Files skipped from review due to trivial changes (12)
- packages/kos-mobile/android/.gitignore
- packages/kos-mobile/android/build.gradle.kts
- packages/kos-mobile/android/gradle.properties
- packages/kos-mobile/android/gradle/libs.versions.toml
- packages/kos-mobile/android/gradle/wrapper/gradle-wrapper.properties
- packages/kos-mobile/android/gradlew
- packages/kos-mobile/android/gradlew.bat
- packages/kos-mobile/android/lib/src/main/AndroidManifest.xml
- packages/kos-mobile/ios/.gitignore
- packages/kos-mobile/ios/framework/.gitignore
- packages/kos-mobile/ios/framework/KOSMobile/KOSMobile/KOSMobile.h
- packages/kos-mobile/src/bin/uniffi-bindgen.rs
Additional context used
Gitleaks
packages/kos-mobile/android/lib/src/test/kotlin/uniffi/kos_mobile/KOSTest.kt
21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
packages/kos-mobile/ios/framework/KOSMobile/KOSMobileTests/KOSMobileTests.swift
22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
SwiftLint
packages/kos-mobile/ios/framework/KOSMobile/KOSMobileTests/KOSMobileTests.swift
[Error] 30-30: Force tries should be avoided
(force_try)
[Error] 33-33: Force tries should be avoided
(force_try)
[Error] 36-36: Force tries should be avoided
(force_try)
[Error] 39-39: Force tries should be avoided
(force_try)
[Error] 42-42: Force tries should be avoided
(force_try)
[Error] 45-45: Force tries should be avoided
(force_try)
[Error] 48-48: Force tries should be avoided
(force_try)
[Error] 51-51: Force tries should be avoided
(force_try)
[Error] 54-54: Force tries should be avoided
(force_try)
[Error] 61-61: Force tries should be avoided
(force_try)
actionlint
.github/workflows/publish-ios.yaml
57-57: shellcheck reported issue in this script: SC2155:warning:3:8: Declare and assign separately to avoid masking return values
(shellcheck)
Shellcheck
packages/kos-mobile/build_source.sh
[warning] 7-7: OS_TOOLCHAIN appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 10-10: ANDROID_JNI_LIBS_PATH appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 11-11: ANDROID_GENERATED_BINDS_PATH appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 13-13: ANDROID_ARCHS appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 14-14: ANDROID_TOOLCHAINS appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 15-15: ANDROID_JNI appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 19-19: IOS_ARCHS appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 20-20: PACKAGE_NAME appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 23-23: ANDROID appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 24-24: IOS appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 92-92: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
Additional comments not posted (101)
packages/kos-mobile/build_clean.sh (3)
8-11
: LGTM!The function correctly removes the specified Android build artifacts.
The code changes are approved.
13-19
: LGTM!The function correctly removes the specified iOS build artifacts.
The code changes are approved.
21-26
: LGTM!The script correctly logs status messages and calls the cleaning functions.
The code changes are approved.
packages/kos-mobile/android/settings.gradle.kts (3)
3-14
: LGTM!The
pluginManagement
block correctly configures the repositories for plugins.The code changes are approved.
16-22
: LGTM!The
dependencyResolutionManagement
block correctly configures the repositories for dependencies.The code changes are approved.
24-25
: LGTM!The project settings correctly configure the root project name and include the module.
The code changes are approved.
.github/workflows/publish-android.yaml (4)
1-4
: LGTM!The
name
andon
blocks correctly set the workflow name and trigger.The code changes are approved.
5-7
: LGTM!The
jobs
block correctly defines the job for publishing the package.The code changes are approved.
8-10
: LGTM!The
env
block correctly sets the environment variables.The code changes are approved.
11-26
: LGTM!The
steps
block correctly defines the steps for the job.The code changes are approved.
packages/kos-mobile/Cargo.toml (5)
1-9
: LGTM!The
[package]
section is correctly configured with workspace attributes for consistency.The code changes are approved.
11-12
: LGTM!The
[lib]
section is correctly configured with appropriate crate types for generating bindings.The code changes are approved.
14-16
: LGTM!The
[[bin]]
section is correctly configured with a binary target foruniffi-bindgen
.The code changes are approved.
18-29
: LGTM!The
[dependencies]
section is correctly configured with workspace dependencies for consistency and maintainability.The code changes are approved.
31-32
: LGTM!The
[build-dependencies]
section is correctly configured withuniffi
as a build dependency from the workspace.The code changes are approved.
packages/kos-sdk/Cargo.toml (1)
43-43
: LGTM!The addition of
lazy_static
as a workspace dependency is a good enhancement for performance and memory management.The code changes are approved.
Makefile (6)
39-40
: LGTM!The target
clean-mobile-build
is correctly configured to clean the mobile build environment for thekos-mobile
package.The code changes are approved.
42-43
: LGTM!The target
build-android
is correctly configured to build the Android application for thekos-mobile
package.The code changes are approved.
45-46
: LGTM!The target
publish-android
is correctly configured to publish the Android library to a GitHub Packages repository.The code changes are approved.
48-49
: LGTM!The target
build-ios
is correctly configured to build the iOS application for thekos-mobile
package.The code changes are approved.
51-58
: LGTM!The target
test-ios
is correctly configured to test the iOS application usingxcodebuild
with specified parameters for the iOS Simulator.The code changes are approved.
60-61
: LGTM!The target
test-android
is correctly configured to test the Android application using Gradle.The code changes are approved.
Cargo.toml (4)
9-9
: LGTM!The addition of
packages/kos-mobile
to themembers
list is correct.The code changes are approved.
45-45
: LGTM!The addition of the
uniffi
dependency is correct and necessary for generating bindings for mobile platforms.The code changes are approved.
54-54
: LGTM!The addition of the
lazy_static
dependency is correct and useful for static initialization.The code changes are approved.
55-55
: LGTM!The addition of the
thiserror
dependency is correct and useful for error handling.The code changes are approved.
packages/kos-mobile/android/lib/build.gradle.kts (9)
1-2
: LGTM!The imports of
java.net.URI
andjava.util.Properties
are necessary for the configuration and publishing tasks.The code changes are approved.
4-8
: LGTM!The applied plugins for Android library, Kotlin, and Maven publishing are necessary for building and publishing the Android library.
The code changes are approved.
10-11
: LGTM!The group and version settings are appropriate for the library.
The code changes are approved.
13-33
: LGTM!The Android configuration settings are appropriate and necessary for building the Android library.
The code changes are approved.
36-39
: LGTM!The dependencies for JNA and JUnit are necessary for the library's functionality and testing.
The code changes are approved.
41-52
: LGTM!The publishing configuration for GitHub Packages is appropriate and necessary.
The code changes are approved.
55-61
: LGTM!The publications configuration for the
KOS
Maven publication is appropriate and necessary.The code changes are approved.
65-71
: LGTM!The task for copying the Darwin library for testing is appropriate and necessary.
The code changes are approved.
73-77
: LGTM!The afterEvaluate block to ensure the copy task runs before tests is appropriate and necessary.
The code changes are approved.
packages/kos-mobile/android/lib/src/test/kotlin/uniffi/kos_mobile/KOSTest.kt (8)
1-1
: LGTM!The package declaration is appropriate for the test file.
The code changes are approved.
3-5
: LGTM!The imports of JUnit assertions are necessary for the test assertions.
The code changes are approved.
8-8
: LGTM!The class declaration is appropriate for the test file.
The code changes are approved.
10-11
: LGTM!The test method declaration is appropriate for the test file.
The code changes are approved.
23-28
: LGTM!The tests for validating mnemonics are appropriate and necessary.
The code changes are approved.
30-34
: LGTM!The tests for generating mnemonics are appropriate and necessary.
The code changes are approved.
36-52
: LGTM!The tests for encrypting and decrypting data are appropriate and necessary.
The code changes are approved.
54-66
: LGTM!The tests for generating wallets from mnemonics and private keys are appropriate and necessary.
The code changes are approved.
packages/kos-mobile/ios/framework/KOSMobile/KOSMobile.xcodeproj/xcshareddata/xcschemes/KOSMobile.xcscheme (6)
5-24
: LGTM!The BuildAction section is correctly configured.
The code changes are approved.
25-44
: LGTM!The TestAction section is correctly configured.
The code changes are approved.
45-55
: LGTM!The LaunchAction section is correctly configured.
The code changes are approved.
56-71
: LGTM!The ProfileAction section is correctly configured.
The code changes are approved.
72-74
: LGTM!The AnalyzeAction section is correctly configured.
The code changes are approved.
75-78
: LGTM!The ArchiveAction section is correctly configured.
The code changes are approved.
packages/kos-mobile/build_ios.sh (5)
8-13
: LGTM!The
configure_cargo
function is correctly implemented.The code changes are approved.
15-22
: LGTM!The
assemble_ios_lib
function is correctly implemented.The code changes are approved.
24-29
: LGTM!The
generate_binds
function is correctly implemented.The code changes are approved.
31-83
: LGTM!The
generate_xcframework
function is correctly implemented.The code changes are approved.
85-97
: LGTM!The main script execution is correctly implemented.
The code changes are approved.
packages/kos-mobile/ios/framework/KOSMobile/KOSMobileTests/KOSMobileTests.swift (2)
11-13
: LGTM!The test case setup is correctly implemented.
The code changes are approved.
24-28
: LGTM!The mnemonic validation tests are correctly implemented.
The code changes are approved.
.github/workflows/publish-ios.yaml (16)
1-4
: LGTM!The workflow is correctly triggered on release creation.
The code changes are approved.
5-6
: LGTM!The permissions are correctly set to write contents.
The code changes are approved.
7-9
: LGTM!The job is correctly configured to run on macOS 14.
The code changes are approved.
10-11
: LGTM!The environment variable
TERM
is correctly set toxterm
.The code changes are approved.
12-17
: LGTM!The repository is correctly checked out with submodules and full depth.
The code changes are approved.
18-22
: Ensure proper error handling for external commands.The build and test steps are correctly implemented, but consider adding error handling for external commands like
brew install protobuf
.Ensure that the external commands are correctly handled in case of failure.
23-25
: LGTM!The checksum is correctly generated for the framework.
The code changes are approved.
26-30
: LGTM!The checksum is correctly uploaded as an artifact.
The code changes are approved.
31-37
: LGTM!The release asset is correctly uploaded using the
softprops/action-gh-release
action.The code changes are approved.
39-41
: LGTM!The job is correctly configured to run on macOS 14 and depends on the
upload-xcframework
job.The code changes are approved.
42-44
: LGTM!The environment variables
TERM
andGITHUB_TOKEN
are correctly set.The code changes are approved.
45-50
: LGTM!The repository is correctly checked out with the specified token.
The code changes are approved.
51-55
: LGTM!The checksum is correctly downloaded as an artifact.
The code changes are approved.
65-71
: LGTM!The changes are correctly committed and pushed.
The code changes are approved.
72-91
: LGTM!The release is correctly created using the GitHub API.
The code changes are approved.
56-64
: Fix shellcheck warning SC2155.Declare and assign separately to avoid masking return values.
- TAG_NAME=${GITHUB_REF#refs/tags/} + TAG_NAME="${GITHUB_REF#refs/tags/}"Apply this diff to fix the issue.
Likely invalid or redundant comment.
Tools
actionlint
57-57: shellcheck reported issue in this script: SC2155:warning:3:8: Declare and assign separately to avoid masking return values
(shellcheck)
packages/kos-mobile/build_android.sh (5)
8-22
: Ensure proper error handling for external commands.The function is correctly implemented, but consider adding error handling for external commands like
rustup target add $toolchain
.Ensure that the external commands are correctly handled in case of failure.
24-40
: Ensure proper error handling for external commands.The function is correctly implemented, but consider adding error handling for external commands like
cargo build --target $rust_toolchain --release -q
.Ensure that the external commands are correctly handled in case of failure.
42-50
: Ensure proper error handling for external commands.The function is correctly implemented, but consider adding error handling for external commands like
cargo build --release -q
.Ensure that the external commands are correctly handled in case of failure.
52-59
: Ensure proper error handling for external commands.The function is correctly implemented, but consider adding error handling for external commands like
cargo run -q --bin uniffi-bindgen generate
.Ensure that the external commands are correctly handled in case of failure.
62-80
: Ensure proper error handling for external commands.The script is correctly implemented, but consider adding error handling for external commands like
configure_android_ndk
andconfigure_openssl
.Ensure that the external commands are correctly handled in case of failure.
packages/kos-mobile/build_source.sh (7)
29-34
: LGTM!The function is correctly implemented.
The code changes are approved.
37-42
: LGTM!The function is correctly implemented.
The code changes are approved.
45-47
: LGTM!The function is correctly implemented.
The code changes are approved.
49-51
: LGTM!The function is correctly implemented.
The code changes are approved.
53-67
: Ensure proper error handling for external commands.The function is correctly implemented, but consider adding error handling for external commands like
curl -0 https://dl.google.com/android/repository/android-ndk-r26b-darwin.dmg
.Ensure that the external commands are correctly handled in case of failure.
69-86
: Ensure proper error handling for external commands.The function is correctly implemented, but consider adding error handling for external commands like
curl -L -o "$OPENSSL_VERSION".tar.gz https://github.com/openssl/openssl/releases/download/"$OPENSSL_VERSION"/"$OPENSSL_VERSION".tar.gz
.Ensure that the external commands are correctly handled in case of failure.
88-116
: Ensure proper error handling for external commands.The script is correctly implemented, but consider adding error handling for external commands like
./Configure "$arch" no-asm no-shared
.Ensure that the external commands are correctly handled in case of failure.
Tools
Shellcheck
[warning] 92-92: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
packages/kos-sdk/src/chain.rs (2)
69-71
: LGTM!The
get_by_code
method is correctly implemented.The code changes are approved.
73-75
: LGTM!The
get_chains
method is correctly implemented.The code changes are approved.
packages/kos-mobile/src/lib.rs (9)
13-33
: LGTM!The error handling is correctly implemented, providing meaningful error messages and conversions.
The code changes are approved.
35-42
: LGTM!The
KOSAccount
struct is correctly implemented.The code changes are approved.
44-47
: LGTM!The
generate_mnemonic
function is correctly implemented and handles errors appropriately.The code changes are approved.
49-52
: LGTM!The
validate_mnemonic
function is correctly implemented and returns a boolean indicating the validity of the mnemonic.The code changes are approved.
75-89
: LGTM!The
generate_wallet_from_private_key
function is correctly implemented and handles errors appropriately.The code changes are approved.
91-107
: LGTM!The encryption functions are correctly implemented and handle errors appropriately.
The code changes are approved.
109-114
: LGTM!The
decrypt
function is correctly implemented and handles errors appropriately.The code changes are approved.
116-121
: LGTM!The
get_chain_by
function is correctly implemented and handles errors appropriately.The code changes are approved.
123-307
: LGTM!The tests are comprehensive and cover various scenarios, including success and failure cases.
The code changes are approved.
packages/kos-mobile/ios/framework/KOSMobile/KOSMobile.xcodeproj/project.pbxproj (6)
9-17
: LGTM!The PBXBuildFile section is correctly implemented and includes the necessary references.
The code changes are approved.
19-27
: LGTM!The PBXContainerItemProxy section is correctly implemented and includes the necessary proxy.
The code changes are approved.
29-39
: LGTM!The PBXFileReference section is correctly implemented and includes the necessary references.
The code changes are approved.
41-58
: LGTM!The PBXFrameworksBuildPhase section is correctly implemented and includes the necessary references.
The code changes are approved.
61-108
: LGTM!The PBXGroup section is correctly implemented and includes the necessary references.
The code changes are approved.
111-512
: LGTM!The remaining sections are correctly implemented and include the necessary references and settings.
The code changes are approved.
packages/kos-mobile/ios/framework/KOSMobile/KOSMobileTests/KOSMobileTests.swift
Show resolved
Hide resolved
packages/kos-mobile/ios/framework/KOSMobile/KOSMobileTests/KOSMobileTests.swift
Show resolved
Hide resolved
packages/kos-mobile/ios/framework/KOSMobile/KOSMobileTests/KOSMobileTests.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- packages/kos-mobile/src/lib.rs (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/kos-mobile/src/lib.rs
Description
This pull request configures the Uniffi library from mozilla/uniffi-rs to generate bindings for both Android and iOS from the Rust code in this repository. The configuration was done using Procedural Macros, eliminating the need for a UDL file.
A new module named kos-mobile was created, which generates the necessary code for both Android and iOS. In this module, functions with signatures compatible with Uniffi were implemented. Additionally, tests were conducted for these functions within Rust, as well as for the iOS and Android libraries.
Summary by CodeRabbit
New Features
Documentation
.gitignore
files for Android and iOS directories to maintain a clean repository.Tests